<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="设备编码" prop="fdDeviceCode">
        <el-input
          v-model="queryParams.fdDeviceCode"
          placeholder="请输入设备编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备名称" prop="fdDeviceName">
        <el-input
          v-model="queryParams.fdDeviceName"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备通用型号" prop="fdUniversalModelOfEquipment">
        <el-input
          v-model="queryParams.fdUniversalModelOfEquipment"
          placeholder="请输入设备通用型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备通用名称" prop="fdUniversalNameOfEquipment">
        <el-input
          v-model="queryParams.fdUniversalNameOfEquipment"
          placeholder="请输入设备通用名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="fdSpec">
        <el-input
          v-model="queryParams.fdSpec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="fdSupplyName">
        <el-input
          v-model="queryParams.fdSupplyName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制造商名称" prop="fdManufacturersName">
        <el-input
          v-model="queryParams.fdManufacturersName"
          placeholder="请输入制造商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="固定资产编号" prop="fdFixedAssetsNo">
        <el-input
          v-model="queryParams.fdFixedAssetsNo"
          placeholder="请输入固定资产编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ys:onboardDeviceManagement:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ys:onboardDeviceManagement:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ys:onboardDeviceManagement:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ys:onboardDeviceManagement:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="onboardDeviceManagementList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键编码" align="center" prop="id" />
      <el-table-column label="序号" align="center" prop="fdSerialNum" />
      <el-table-column label="组织名称" align="center" prop="fdOrganizationName" />
      <el-table-column label="组织代码" align="center" prop="fdOrganizationCode" />
      <el-table-column label="组织分类" align="center" prop="fdOrganizationCategory" />
      <el-table-column label="组织层级" align="center" prop="fdOrganizationLevel" />
      <el-table-column label="设备类型" align="center" prop="fdDeviceType1" />
      <el-table-column label="设备编码" align="center" prop="fdDeviceCode" />
      <el-table-column label="设备类别" align="center" prop="fdDeviceType" />
      <el-table-column label="设备大类" align="center" prop="fdDeviceTyp3">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.equipment_category" :value="scope.row.fdDeviceTyp3"/>
        </template>
      </el-table-column>
      <el-table-column label="设备名称" align="center" prop="fdDeviceName" />
      <el-table-column label="设备通用型号" align="center" prop="fdUniversalModelOfEquipment" />
      <el-table-column label="设备通用名称" align="center" prop="fdUniversalNameOfEquipment" />
      <el-table-column label="规格型号" align="center" prop="fdSpec" />
      <el-table-column label="设备功率" align="center" prop="fdDevicePower" />
      <el-table-column label="设备序列码" align="center" prop="fdDeviceSeq" />
      <el-table-column label="设备标记" align="center" prop="fdDeviceIsFlag" />
      <el-table-column label="购置时间" align="center" prop="fdPurchaseTime" width="180"/>
      <el-table-column label="资产负责人" align="center" prop="fdChargePerson" />
      <el-table-column label="使用寿命" align="center" prop="fdServiceLife" />
      <el-table-column label="供应商编码" align="center" prop="fdSupplyId" />
      <el-table-column label="供应商名称" align="center" prop="fdSupplyName" />
      <el-table-column label="制造商编码" align="center" prop="fdMakerCode" />
      <el-table-column label="制造商名称" align="center" prop="fdManufacturersName" />
      <el-table-column label="使用部门" align="center" prop="fdUseDept" />
      <el-table-column label="使用状况" align="center" prop="fdUseStatus" />
      <el-table-column label="设备位置" align="center" prop="fdDevicePosition" />
      <el-table-column label="设备地址" align="center" prop="fdDeviceAddress" />
      <el-table-column label="ip地址" align="center" prop="fdIpAddress" />
      <el-table-column label="MAC地址" align="center" prop="fdMacAddress" />
      <el-table-column label="操作人员" align="center" prop="fdOperator" />
      <el-table-column label="固定资产编号" align="center" prop="fdFixedAssetsNo" />
      <el-table-column label="启用时间" align="center" prop="fdStartDate" width="180"/>
      <el-table-column label="停用时间" align="center" prop="fdStopTime" width="180"/>
      <el-table-column label="报废时间" align="center" prop="fdScrappingTime" width="180"/>
      <el-table-column label="设备图片地址" align="center" prop="fdDeviceImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.fdDeviceImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="设备二维码地址" align="center" prop="fdDeviceEwm" />
      <el-table-column label="设备保养周期" align="center" prop="fdMaintainCycle1" />
      <el-table-column label="设备维护周期" align="center" prop="fdMaintainCycle2" />
      <el-table-column label="设备程序代码" align="center" prop="fdProgramCode" />
      <el-table-column label="设备程序包" align="center" prop="fdProgramPackage" />
      <el-table-column label="备注" align="center" prop="fdRemark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ys:onboardDeviceManagement:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ys:onboardDeviceManagement:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改车载设备管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="序号" prop="fdSerialNum">
              <el-input v-model="form.fdSerialNum" placeholder="请输入序号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织名称" prop="fdOrganizationName">
              <el-input v-model="form.fdOrganizationName" placeholder="请输入组织名称" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织代码" prop="fdOrganizationCode">
              <el-input v-model="form.fdOrganizationCode" placeholder="请输入组织代码" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织层级" prop="fdOrganizationLevel">
              <el-input v-model="form.fdOrganizationLevel" placeholder="请输入组织层级" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备编码" prop="fdDeviceCode">
              <el-input v-model="form.fdDeviceCode" placeholder="请输入设备编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备大类" prop="fdDeviceTyp3">
              <el-select v-model="form.fdDeviceTyp3" placeholder="请选择设备大类">
                <el-option
                  v-for="dict in dict.type.equipment_category"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备名称" prop="fdDeviceName">
              <el-input v-model="form.fdDeviceName" placeholder="请输入设备名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备通用型号" prop="fdUniversalModelOfEquipment">
              <el-input v-model="form.fdUniversalModelOfEquipment" placeholder="请输入设备通用型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备通用名称" prop="fdUniversalNameOfEquipment">
              <el-input v-model="form.fdUniversalNameOfEquipment" placeholder="请输入设备通用名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="fdSpec">
              <el-input v-model="form.fdSpec" placeholder="请输入规格型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备功率" prop="fdDevicePower">
              <el-input v-model="form.fdDevicePower" placeholder="请输入设备功率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备序列码" prop="fdDeviceSeq">
              <el-input v-model="form.fdDeviceSeq" placeholder="请输入设备序列码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备标记" prop="fdDeviceIsFlag">
              <el-input v-model="form.fdDeviceIsFlag" placeholder="请输入设备标记" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="购置时间" prop="fdPurchaseTime">
              <el-date-picker clearable
                v-model="form.fdPurchaseTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择购置时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资产负责人" prop="fdChargePerson">
              <el-input v-model="form.fdChargePerson" placeholder="请输入资产负责人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用寿命" prop="fdServiceLife">
              <el-input v-model="form.fdServiceLife" placeholder="请输入使用寿命" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编码" prop="fdSupplyId">
              <el-input v-model="form.fdSupplyId" placeholder="请输入供应商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="fdSupplyName">
              <el-input v-model="form.fdSupplyName" placeholder="请输入供应商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造商编码" prop="fdMakerCode">
              <el-input v-model="form.fdMakerCode" placeholder="请输入制造商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造商名称" prop="fdManufacturersName">
              <el-input v-model="form.fdManufacturersName" placeholder="请输入制造商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用部门" prop="fdUseDept">
              <el-input v-model="form.fdUseDept" placeholder="请输入使用部门" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备位置" prop="fdDevicePosition">
              <el-input v-model="form.fdDevicePosition" placeholder="请输入设备位置" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备地址" prop="fdDeviceAddress">
              <el-input v-model="form.fdDeviceAddress" placeholder="请输入设备地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="ip地址" prop="fdIpAddress">
              <el-input v-model="form.fdIpAddress" placeholder="请输入ip地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="MAC地址" prop="fdMacAddress">
              <el-input v-model="form.fdMacAddress" placeholder="请输入MAC地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="操作人员" prop="fdOperator">
              <el-input v-model="form.fdOperator" placeholder="请输入操作人员" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="固定资产编号" prop="fdFixedAssetsNo">
              <el-input v-model="form.fdFixedAssetsNo" placeholder="请输入固定资产编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="启用时间" prop="fdStartDate">
              <el-date-picker clearable
                v-model="form.fdStartDate"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择启用时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="停用时间" prop="fdStopTime">
              <el-date-picker clearable
                v-model="form.fdStopTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择停用时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报废时间" prop="fdScrappingTime">
              <el-date-picker clearable
                v-model="form.fdScrappingTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择报废时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="设备图片地址" prop="fdDeviceImg">
              <image-upload v-model="form.fdDeviceImg"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备二维码地址" prop="fdDeviceEwm">
              <el-input v-model="form.fdDeviceEwm" placeholder="请输入设备二维码地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备保养周期" prop="fdMaintainCycle1">
              <el-input v-model="form.fdMaintainCycle1" placeholder="请输入设备保养周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备维护周期" prop="fdMaintainCycle2">
              <el-input v-model="form.fdMaintainCycle2" placeholder="请输入设备维护周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备程序代码" prop="fdProgramCode">
              <el-input v-model="form.fdProgramCode" placeholder="请输入设备程序代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备程序包" prop="fdProgramPackage">
              <el-input v-model="form.fdProgramPackage" placeholder="请输入设备程序包" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="fdRemark">
              <el-input v-model="form.fdRemark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <organizationalSelect ref="organizationalSelect" @onSelected="onSelected"></organizationalSelect>
  </div>
</template>

<script>
import { listOnboardDeviceManagement, getOnboardDeviceManagement, delOnboardDeviceManagement, addOnboardDeviceManagement, updateOnboardDeviceManagement } from "@/api/ys/onboardDeviceManagement";
import {getToken} from "@/utils/auth";
export default {
  name: "OnboardDeviceManagement",
  dicts: ['equipment_category'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 车载设备管理表格数据
      onboardDeviceManagementList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fdDeviceType1: null,
        fdDeviceCode: null,
        fdDeviceName: null,
        fdUniversalModelOfEquipment: null,
        fdUniversalNameOfEquipment: null,
        fdSpec: null,
        fdSupplyName: null,
        fdManufacturersName: null,
        fdFixedAssetsNo: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`onboardDeviceManagement`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/ys/onboardDeviceManagement/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /*选择组织*/
    selectOrganization() {
      this.$refs['organizationalSelect'].show()
    },
    /*选择组织组件回调*/
    /*参数：组织信息*/
    onSelected(org) {
      this.form.fdOrganizationCode=org.gcdm
      this.form.fdOrganizationName=org.gcmc
    },
    /** 查询车载设备管理列表 */
    getList() {
      this.loading = true;
      listOnboardDeviceManagement(this.queryParams).then(response => {
        this.onboardDeviceManagementList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        fdSerialNum: null,
        fdOrganizationName: null,
        fdOrganizationCode: null,
        fdOrganizationCategory: null,
        fdOrganizationLevel: null,
        fdDeviceType1: null,
        fdDeviceCode: null,
        fdDeviceType: null,
        fdDeviceTyp3: null,
        fdDeviceName: null,
        fdUniversalModelOfEquipment: null,
        fdUniversalNameOfEquipment: null,
        fdSpec: null,
        fdDevicePower: null,
        fdDeviceSeq: null,
        fdDeviceIsFlag: null,
        fdPurchaseTime: null,
        fdChargePerson: null,
        fdServiceLife: null,
        fdSupplyId: null,
        fdSupplyName: null,
        fdMakerCode: null,
        fdManufacturersName: null,
        fdUseDept: null,
        fdUseStatus: null,
        fdDevicePosition: null,
        fdDeviceAddress: null,
        fdIpAddress: null,
        fdMacAddress: null,
        fdOperator: null,
        fdFixedAssetsNo: null,
        fdStartDate: null,
        fdStopTime: null,
        fdScrappingTime: null,
        fdDeviceImg: null,
        fdDeviceEwm: null,
        fdMaintainCycle1: null,
        fdMaintainCycle2: null,
        fdProgramCode: null,
        fdProgramPackage: null,
        fdRemark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加车载设备管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getOnboardDeviceManagement(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改车载设备管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateOnboardDeviceManagement(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOnboardDeviceManagement(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delOnboardDeviceManagement(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('ys/onboardDeviceManagement/export', {
        ...this.queryParams
      }, `onboardDeviceManagement_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "车载设备管理导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('ys/onboardDeviceManagement/importTemplate', {
      }, `车载设备管理模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
